import React from 'react';
import { Button,  Modal, Table, } from 'antd';

export default class AddressHistoryModal extends React.Component {
  state = {
    addressVisible: false,
    list: [],
  }
  componentDidMount() {
  }

  setStateData = (data) => {
    this.setState({
      ...data
    })
  }

  handleOpen = () => {
    this.setState({
      addressVisible: true
    });
  }

  onClose = () => {
    this.setState({
      addressVisible: false
    })
  }

  onClick = (record) => {
    this.props.handleSetAddress(record);
    this.setState({
      addressVisible: false
    })
  }

  render() {
    const { addressVisible,list } = this.state;
    const columns = [
      {
        title: '二网地址',
        dataIndex: 'address',
        width: '100%',
        render: (text) => {
          return text;
        },
      }];

    return (
      <Modal
        // width="60%"
        title="选择二网历史地址"
        visible={addressVisible}
        onCancel={() => this.onClose()}
        footer={[
          <Button key="back" size="default" onClick={() => this.onClose()}>
            返回
          </Button>,
        ]}
      >
        <Table
          size="small"
          style={{ overflow: 'auto', height: 320 }}
          onRowClick= {record=> this.onClick(record)}
          columns={columns}
          dataSource={list}
          pagination={false}
        />
      </Modal>
    );
  }
}

